//
//  UserDefaults.swift
//  QNN
//
//  Created by zhenyu on 17/5/12.
//  Copyright © 2017年 qianshengqian. All rights reserved.
//

import Foundation


class User {
  static func save(obj: AnyObject, key: String) {
    let userDefaults = UserDefaults.standard
    userDefaults.set(obj, forKey: key)
    userDefaults.synchronize()
  }
  
  
  /// 选中的域名
  static var seletedDomain: String {
    set {
      User.save(obj: newValue as AnyObject, key: "seletedDomain")
    }
    get {
      let userDefaults = UserDefaults.standard
      return userDefaults.string(forKey: "seletedDomain") ?? "http://lmd.qianshengqian.com"
    }
  }
  
  
  /// Token
  static var token: String {
    set {
      User.save(obj: newValue as AnyObject, key: "userToken")
    }
    get {
      let userDefaults = UserDefaults.standard
      return userDefaults.string(forKey: "userToken") ?? ""
    }
  }
  
  /// UID
  static var uid: String {
    set {
      User.save(obj: newValue as AnyObject, key: "uid")
    }
    get {
      let userDefaults = UserDefaults.standard
      return userDefaults.string(forKey: "uid") ?? ""
    }
  }

  
  /// 手机号码
  static var phone: String {
    set {
      User.save(obj: newValue as AnyObject, key: "phone")
    }
    get {
      let userDefaults = UserDefaults.standard
      return userDefaults.string(forKey: "phone") ?? ""
    }
  }
}


